package com.ddwl.gate.controller;

import com.ddwl.common.annotation.Auth;
import com.ddwl.common.constant.BaseEnum;
import com.ddwl.common.controller.BaseController;
import com.ddwl.gate.service.DingTalkService;
import com.ddwl.gate.service.SupportService;
import com.ddwl.gate.util.RobotHelperUtil;
import com.ddwl.schema.bo.base.PageBo;
import com.ddwl.schema.bo.gate.DingTalkBo;
import com.ddwl.schema.bo.gate.SupportBo;
import com.ddwl.schema.bo.goods.SupplierBo;
import com.ddwl.schema.vo.base.PageVo;
import com.ddwl.schema.vo.base.RestVo;
import com.ddwl.schema.vo.gate.SupportVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Arrays;
import java.util.List;

/**
 * 帮助中心接口
 * @author wenbin
 */
@Api(tags = "帮助中心接口")
@RequestMapping("/support")
@RestController
public class SupportController extends BaseController {
    
    @Resource
    private SupportService supportService;


    @PostMapping("/add")
    @Auth(product = {BaseEnum.ProductEnum.CONSOLE})
    @ApiOperation("新增帮助")
    public RestVo add(@Valid @RequestBody SupportBo bo) {
        supportService.add(bo);
        return RestVo.ok();
    }

    @PostMapping("/update")
    @Auth(product = {BaseEnum.ProductEnum.CONSOLE})
    @ApiOperation("修改帮助")
    public RestVo update(@Valid @RequestBody SupportBo bo){
        supportService.update(bo);
        return RestVo.ok();
    }


    @GetMapping("/get/{id}")
    @Auth(product = {BaseEnum.ProductEnum.WBM, BaseEnum.ProductEnum.WBM_OFFICE,BaseEnum.ProductEnum.MALL,BaseEnum.ProductEnum.FENXIAO, BaseEnum.ProductEnum.BYTE_DANCE})
    @ApiOperation("帮助详情 小程序")
    public RestVo<SupportVo> get(@PathVariable("id") String id){
        SupportVo supportVo = supportService.get(id);
        return RestVo.ok(supportVo);
    }

    @GetMapping("/getForConsole/{id}")
    @Auth(product = {BaseEnum.ProductEnum.CONSOLE})
    @ApiOperation("帮助详情 多典后台")
    public RestVo<SupportVo> getForConsole(@PathVariable("id") String id){
        SupportVo supportVo = supportService.getForConsole(id);
        return RestVo.ok(supportVo);
    }

    @DeleteMapping("/delete/{id}")
    @Auth(product = {BaseEnum.ProductEnum.CONSOLE})
    @ApiOperation("删除帮助")
    public RestVo delete(@PathVariable("id") String id){
        supportService.delete(id);
        return RestVo.ok();
    }

    @PostMapping("/page")
    @Auth(product = {BaseEnum.ProductEnum.WBM, BaseEnum.ProductEnum.WBM_OFFICE,BaseEnum.ProductEnum.MALL,BaseEnum.ProductEnum.FENXIAO, BaseEnum.ProductEnum.BYTE_DANCE})
    @ApiOperation("帮助分页 小程序")
    public RestVo<PageVo<SupportVo>> page(@RequestBody PageBo<SupportBo> pageBo){
        pageBo.getParam().setEffect(1);
        return RestVo.ok(supportService.page(pageBo));
    }

    @PostMapping("/pageForConsole")
    @Auth(product = {BaseEnum.ProductEnum.CONSOLE})
    @ApiOperation("帮助分页 多典后台")
    public RestVo<PageVo<SupportVo>> pageForConsole(@RequestBody PageBo<SupportBo> pageBo){
        return RestVo.ok(supportService.page(pageBo));
    }

    @PostMapping("/effect")
    @Auth(product = {BaseEnum.ProductEnum.CONSOLE})
    @ApiOperation("启用禁用")
    public RestVo effect(@RequestBody SupportBo bo){
        supportService.effect(bo);
        return RestVo.ok();
    }


}
